#include <iostream>
#include <list>
#include <iterator>
#include <vector>
using namespace std;

#include "Simulator.h"
//#include "Tower.h"
#include "Elements/Robot.h"
//#include "FloorTile.h"
//#include "Bunny.h"
//#include "Position.h"

int main(int, char **)
{
    Simulator simulator(8,8);
    
    Robot * robot;
    Robot * robot1 = new Robot(Position(0, 3));
    Robot * robot2 = new Robot(Position(3, 1));
    Robot * robot3 = new Robot(Position(3, 3));

//    simulator.addElement(new Tower(Position(8,8)));
//    simulator.addElement(new Bunny(Position(0,0)));
//    for( int i = 0 ; i < 64 ; ++i)
//        simulator.addElement(new FloorTile(Position(i%8, i/8)));
    
    simulator.addGhost(robot1);
    simulator.addGhost(robot2);
    simulator.addGhost(robot3);

    char dir;
    char num;
    
    std::cout << "u(p), l(eft), r(ight), d(down), q(uit), 1 2 3 (robot choice)" << std::endl;
    robot = robot1;
     
     // beetje extra
    robot1->scheduleUp();simulator.simulateSingleTimeFrame();
    robot1->scheduleUp();simulator.simulateSingleTimeFrame();
    robot1->scheduleUp();simulator.simulateSingleTimeFrame();
    robot1->scheduleUp();simulator.simulateSingleTimeFrame();
    robot1->scheduleRight();simulator.simulateSingleTimeFrame();
    robot1->scheduleRight();simulator.simulateSingleTimeFrame();
    robot1->scheduleRight();simulator.simulateSingleTimeFrame();
    robot1->scheduleRight();simulator.simulateSingleTimeFrame();
    
    robot2->scheduleUp();simulator.simulateSingleTimeFrame();
    //get out of the way for robot3
    robot2->scheduleRight();simulator.simulateSingleTimeFrame();
    
    robot3->scheduleUp();simulator.simulateSingleTimeFrame();
    robot3->scheduleUp();simulator.simulateSingleTimeFrame();
    robot3->scheduleUp();simulator.simulateSingleTimeFrame();
    robot3->scheduleUp();simulator.simulateSingleTimeFrame();
    robot3->scheduleUp();simulator.simulateSingleTimeFrame();
    robot3->scheduleUp();simulator.simulateSingleTimeFrame();
    robot3->scheduleUp();simulator.simulateSingleTimeFrame();
    robot3->scheduleRight();simulator.simulateSingleTimeFrame();
    robot3->scheduleRight();simulator.simulateSingleTimeFrame();
    robot3->scheduleRight();simulator.simulateSingleTimeFrame();
    robot3->scheduleRight();simulator.simulateSingleTimeFrame();
    robot3->scheduleRight();simulator.simulateSingleTimeFrame();
    robot3->scheduleRight();simulator.simulateSingleTimeFrame();
    robot3->scheduleRight();simulator.simulateSingleTimeFrame();
    robot3->scheduleRight();simulator.simulateSingleTimeFrame();
     
    //normaal zou de spel per programmeer kaart dat ie uitvoert, dit oproepen
    while(true)
    { 
        simulator.printUniverse();
    
        std::cin >> dir;
        switch(dir)
        {
//        case 's':
//            robot->scheduleSpawn();
//            simulator.simulateSingleTimeFrame();
//            break;
        case 'u':
            robot->scheduleUp();
            simulator.simulateSingleTimeFrame();
            break;
        case 'd':
            robot->scheduleDown();
            simulator.simulateSingleTimeFrame();
            break;
        case 'l':
            robot->scheduleLeft();
            simulator.simulateSingleTimeFrame();
            break;
        case 'r':
            robot->scheduleRight();
            simulator.simulateSingleTimeFrame();
            break;
        case '1':
            robot = robot1;
            break;
        case '2':
            robot = robot2;
            break;
        case '3':
            robot = robot3;
            break;
        case 'q':
                goto exit;
        default:
            break;
        }
    }
    
exit:
    
    delete robot1;
    delete robot2;
    delete robot3;

    return 0;
}

